CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

#project name
PROJECT(LogPublisherSample)

set(CMAKE_CXX_FLAGS "-g -Wall")
#introot definition
SET(INTROOT $ENV{INTROOT})
IF(NOT INTROOT)
    SET(INTROOT $ENV{SWROOT})
    SET(SWROOT $ENV{SWROOT})
    IF(NOT SWROOT)
        SET(CMAKE_INSTALL_PREFIX="/tmp/Logger")
        MESSAGE("Nor INTROOT neither SWROOT defined, CMAKE_INSTALL_PREFIX set to: /tmp/Logger")
    ELSE(NOT SWROOT) 
        SET(CMAKE_INSTALL_PREFIX ${SWROOT})
        MESSAGE("No INTROOT defined. Using SWROOT, CMAKE_INSTALL_PREFIX set to: $ENV{SWROOT}")
    ENDIF(NOT SWROOT)
ELSE(NOT INTROOT)
    SET(CMAKE_INSTALL_PREFIX ${INTROOT})
    MESSAGE("CMAKE_INSTALL_PREFIX set to: $ENV{INTROOT}")
ENDIF(NOT INTROOT)
SET(LCU $ENV{TYPE})

IF(LCU)
    ADD_DEFINITIONS(-DLCU -DICEE_PURE_CLIENT)
ENDIF(LCU)

#SET_TARGET_PROPERTIES(publisherT PROPERTIES LINKER_LANGUAGE CXX)
#for .h file search
INCLUDE_DIRECTORIES(/usr/lib/include)
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/../include")
INCLUDE_DIRECTORIES("${INTROOT}/include")
INCLUDE_DIRECTORIES("$ENV{SWROOT}/include")
LINK_DIRECTORIES(${INTROOT}/lib $ENV{SWROOT}/lib)


ADD_LIBRARY(LoggerCore SHARED LoggerHelper)
set_property(TARGET LoggerCore PROPERTY LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../lib)

ADD_EXECUTABLE(publisherDummyT publisherDummyTest)
TARGET_LINK_LIBRARIES(publisherDummyT LoggerCore)

#for make install
INSTALL(TARGETS publisherDummyT
    RUNTIME DESTINATION ${INTROOT}/bin
    LIBRARY DESTINATION ${INTROOT}/lib
    ARCHIVE DESTINATION ${INTROOT}/lib
)

#install .h 
INSTALL(
   DIRECTORY ${PROJECT_SOURCE_DIR}/../include/ DESTINATION include 
   FILES_MATCHING PATTERN "*.h"
)

INSTALL(
   DIRECTORY ${PROJECT_SOURCE_DIR}/../lib/ DESTINATION  ${INTROOT}/lib
   FILES_MATCHING PATTERN "*.so"
)


